package com.example.dell.widgettest_122;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class  NewActivity extends AppCompatActivity implements View.OnClickListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new);

        Intent intent=getIntent();
        String str=intent.getStringExtra("param1");
       int n=intent.getIntExtra("param2",10);
        System.out.println(str+"---"+String.valueOf(n));//将n转化成String形式
        Toast.makeText(this,str+"---"+String.valueOf(n),Toast.LENGTH_LONG);
        //在TextView中显示
        //获取控件
       TextView tv=(TextView) findViewById(R.id.textView2);
        tv.setText(str+"---"+String.valueOf(n));

        Button btn=(Button)findViewById(R.id.button3);//关闭按钮实例化
        btn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {//对关闭按钮进行监听
        switch (v.getId())
        {
            case R.id.button3:
                finish();
                break;

        }
    }
}
